<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

class LibMemcache {
	var $memcache;
	var $status = false;
	var $timeout = 100;
	
	//constructor
	function LibMemcache() {
		$this->connect();
	}
	
	//methods
	function connect() {
		$this->memcache = new Memcache;
		$this->memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
	}
	
	function set($key, $value) {
		$this->memcache->set($key, $value, $this->status, $this->timeout);
	}
	
	function get($key, $field = '') {
		if( $field == '' ) {
			return $this->memcache->get($key);
		} else {
			$value = $this->memcache->get($key);
			return $value[$field];
		}
	}
}
//
?>